// 深拷贝
export function cloneDeep(target) {
  // 先判断target是不是对象
  if (typeof target !== "object") {
    return target;
  }
  let type = Object.prototype.toString.call(target);
  let data = null;
  if (type == "[object Array]") {
    data = [];
    target.forEach((item, index) => {
      data[index] = cloneDeep(item);
    });
  } else if (type == "[object Object]") {
    data = {};
    for (const k in target) {
      data[k] = cloneDeep(target[k]);
    }
  }
  return data;
}
